package com.fresh.bus.canoe.exception;

public class ServerException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    public static final int SERVER_ERROR = 0;
    public static final int UNIMPLEMENTED_OPRATION = 1;
    public static final int REQUEST_READ_ERROR = 2;
    public static final int REQUEST_DATA_ERROR = 3;
    public static final int RESPONSE_DATA_ERROR = 4;
    public static final int INVALID_COMMAND = 5;
    public static final int INVALID_CALLBACK = 6;
    public static final int ROLE_REQUIRED = 7;

    private int errorCode = 0;

    public ServerException(int errorCode, Throwable cause)
    {
        this(errorCode, cause, null);
    }

    public ServerException(int errorCode, Throwable cause, String message)
    {
        super(message, cause);

        this.errorCode = errorCode;
    }

    public ServerException(int errorCode, String message)
    {
        this(errorCode,  null, message);
    }

    public ServerException(int errorCode)
    {
        this(errorCode, null, null);
    }

    public int getErrorCode() {
        return this.errorCode;
    }
}
